
from model.item import Item,Dao

class Session(Item):
    def __init__(self, _dict): 
        #name, description, year, price, status, # BaseClass
        #style, nrooms, nbaths, ngarages, basement, lots, living_space=None,faces=None, deck=None, patio=None, fence=None, ac=None):
        """Arguments:
            style --- TINYINT 0:single, 1:semi detached, 2:town house, 3:banglo
            floor --- SMALLINT NULL,#0:hardwood, 2:carpet, 3:ceramic, 4:mixed, 5:others
        """
        Item.__init__(self, _dict)
        

        # associate fields
        self.user_id = _dict['user_id']
        self.item_id = _dict['item_id']
        
class SessionDao(Dao):
    def __init__(self):
        """Arguments:
            collection --- string the name of the collection
        """
        Dao.__init__(self, Session)
        self.collection = 'sessions'

    def insert(self, s):
        """Save the object to collection
        Arguments:
            s --- The Model object
        """
        if isinstance(s, Session):
            # Insert except ID field, because ID will be automatically generated
            _dict = {}
            _dict['user_id'] = s.user_id;
            _dict['item_id'] = s.item_id;
            
            return self.db.insert(self.collection, _dict)
        return None        
if __name__ == '__main__':
    # create table
    #db.drop_all()
    #db.create_all()
    pass